#include <string>
#include <iostream>
using namespace std;
class Solution {
public:
    int lengthOfLastWord(string s) {
		if (s.size() == 0 || s == "")
			return 0;	
		int end=s.size()-1;
		while (end>=0&&s[end] == ' ')
			--end;
		//cout <<end<<endl;
		if (end <= 0)
			return end+1;
		
		int start = end;
		while (start>=0 && s[start] != ' ')
			--start;
		return end - start;
    }
};
int main()
{
	cout << Solution().lengthOfLastWord("");
	
}
